/*
'  DotNetNuke -  http://www.dotnetnuke.com
'  Copyright (c) 2002-2011
'  by DotNetNuke Corporation
' 
'  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
'  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
'  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
'  to permit persons to whom the Software is furnished to do so, subject to the following conditions:
' 
'  The above copyright notice and this permission notice shall be included in all copies or substantial portions 
'  of the Software.
' 
'  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
'  TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
'  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
'  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
'  DEALINGS IN THE SOFTWARE.
*/

using System;
using System.Collections.Generic;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Modules.Store.Providers.Cart;

namespace DotNetNuke.Modules.Store.Cart
{
	/// <summary>
	/// Summary description for ItemInfo.
	/// </summary>
    public sealed class ItemInfo : ICartItemInfo, IHydratable
	{
        #region Constructors

        public ItemInfo()
		{
        }

        #endregion

        #region Private Members

        private int itemID;
		private string cartID;
		private int productID;
        private string manufacturer;
        private string modelNumber;
        private string modelName;
        private string productImage;
        private decimal unitCost;
		private int quantity;
		private DateTime dateCreated;
        private decimal productWeight;
        private decimal productHeight;
        private decimal productLength;
        private decimal productWidth;

        #endregion

        #region Public Properties

        public int ItemID
		{
			get {return itemID;}
			set {itemID = value;}
		}

		public string CartID
		{
			get {return cartID;}
			set {cartID = value;}
		}

		public int ProductID
		{
			get {return productID;}
			set {productID = value;}
		}

        public string Manufacturer
        {
            get { return manufacturer; }
            set { manufacturer = value; }
        }

        public string ModelNumber
        {
            get { return modelNumber; }
            set { modelNumber = value; }
        }

        public string ModelName
        {
            get { return modelName; }
            set { modelName = value; }
        }

        public string ProductTitle
        {
            get
            {
                string title = string.Empty;
                title += modelNumber.Trim();
                title += title == string.Empty ? modelName.Trim() : " - " + modelName.Trim();
                return title;
            }
        }

        public string ProductImage
        {
            get { return productImage; }
            set { productImage = value; }
        }

        public decimal UnitCost
        {
            get { return unitCost; }
            set { unitCost = value; }
        }

		public int Quantity
		{
			get {return quantity;}
			set {quantity = value;}
		}

        public decimal SubTotal
        {
            get { return unitCost * quantity; }
        }

		public DateTime DateCreated
		{
			get {return dateCreated;}
			set {dateCreated = value;}
		}

        public decimal ProductWeight
        {
            get { return productWeight; }
            set { productWeight = value; }
        }

        public decimal ProductHeight
        {
            get { return productHeight; }
            set { productHeight = value; }
        }

        public decimal ProductLength
        {
            get { return productLength; }
            set { productLength = value; }
        }

        public decimal ProductWidth
        {
            get { return productWidth; }
            set { productWidth = value; }
        }

        #endregion

        #region IHydratable Members

        public void Fill(System.Data.IDataReader dr)
        {
            itemID = Convert.ToInt32(dr["ItemID"]);
            cartID = Convert.ToString(dr["CartID"]);
            productID = Convert.ToInt32(dr["ProductID"]);
            manufacturer = Convert.ToString(Null.SetNull(dr["Manufacturer"], manufacturer));
            modelNumber = Convert.ToString(Null.SetNull(dr["ModelNumber"], modelNumber));
            modelName = Convert.ToString(Null.SetNull(dr["ModelName"], modelName));
            productImage = Convert.ToString(Null.SetNull(dr["ProductImage"], productImage));
            unitCost = Convert.ToDecimal(dr["UnitCost"]);
            quantity = Convert.ToInt32(dr["Quantity"]);
            dateCreated = Convert.ToDateTime(dr["DateCreated"]);
            productWeight = Convert.ToDecimal(dr["ProductWeight"]);
            productHeight = Convert.ToDecimal(dr["ProductHeight"]);
            productLength = Convert.ToDecimal(dr["ProductLength"]);
            productWidth = Convert.ToDecimal(dr["ProductWidth"]);
       }

        public int KeyID
        {
            get { return itemID; }
            set { itemID = value; }
        }

        #endregion
    }
}
